In This Topic
The Nevron Resource Maker creates an entry in the generated resource class for each file in the resources directory that passes through the include and exclude filters. These entries are called embedded resources and expose three public get-only properties:
- Name - the name of the embedded resource.
- Data - the actual resource data.
- Container - the resource class that contains the embedded resource. This is the base class for the resources class that the Nevron Resource Maker generates.
Resource Containers
The embedded resource container class serves as a base for the resource class generated by the Nevron Resource Maker and provides some useful methods for working with embedded resources:
- GetResource - returns the resource with the specified name or null if a resource with this name does not exist.
- GetResourceBytes - returns the bytes of the resource with the specified name (ore the specified embedded resource) or null if a resource with this name does not exist.
- GetResourceStream - gets a stream from the resource with the specified name. Returns null if a resource with this name does not exist.
- GetResourceNames - gets the names of the resources contained in this container.
Resource References
The embedded resource reference is a value type that contains a resource name and a reference to a resource container and represents a reference to an embedded resource. You can create a resource reference by passing either a resource name and a resource container or an embedded resource to the NEmbeddedResourceRef constructor.
Embedded resource references can be used to create cursors and images from embedded resources. This is widely used by the Nevron Resource Maker, as it automatically creates a reference for every cursor and image embedded as a resource, which makes it easy to access and use embedded cursors and images directly without the need of creating resource references.
Publicly Available Resources
Some of the NOV assemblies include publicly available resources. For example the "Nevron.Nov.Presentation" assembly includes a lot of embedded image resources, which you may use freely in your applications. For example, to create a button with a floppy disk image you can use the following code:
Use an embedded resource |
Copy Code
|
NButton button = NButton.CreateImageAndText(Nevron.Nov.Presentation.NResources.Image_File_Save_png, "Save");
|
This code with result in the following button:
Most of the images are 16x16 and 32x32 icons.
To see all publicly available resources embedded in NOV, check out the example "Framework -> IO & Misc -> Embedded Resources" which comes with NOV. This example is a browser for all resources embedded in the NOV assemblies. When you open the example select a category from the tree view with resources and then click the Copy Code button in the grid next to the image resource you are interested in to copy the code for using it to the clipboard.
See Also